<template>
	<view style="padding-bottom: 40rpx;">
		<!-- 搜索头部 -->
		<view class="mainpadding dingwei">
			<view class="bjsdw"></view>
			<view class="" style="position: relative; z-index: 2;">
				<view class="ffffff flexbetween ssbox">
					<view class="flexleft">
						<u-icon name="search" color="#999" size="20"></u-icon>
						<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold">
					</view>
					<view class="rightss" @click="tzmslb">搜索</view>
				</view>
				<view class="margin_top">
					<u-swiper :list="list1" keyName="image_text" height="160" circular radius="10" @click="lbtclick($event,list1)"></u-swiper>
				</view>
			</view>
		</view>
		<!-- 选择酒店 -->
		<view class="ffffff mainpadding2">
			<scroll-view class="scroll-view_H" scroll-x="true" >
				<view class="flexleft flex_wrap">
					<view class="ershi flexcenter margin_top" v-for="item in leftlist" :key="item.id" @click="jumpsjlb(item.name,4,item.id)">
						<view class="">
							<view class="flicon">
								<image :src="item.image_text" mode=""></image>
							</view>
							<view class="xiaohui ershil textcenter margin_top2">{{item.name}}</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<!-- 推荐酒店 -->
		<view class="margin_top">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="line margin_right"></view>
					<view class="titletext hei_text bold">商家列表</view>
				</view>
				<view class="flexright margin_right" @click="jumpsjlb(navname,4,category_id)">
					<view class="xiaohuang margin_right1 main_size">查看全部</view>
					<u-icon name="arrow-right" color="#ff9341" size="12"></u-icon>
				</view>
			</view>
			<!-- <view class="" style="padding: 0 30rpx 0;">
				<view class="mainpadding ffffff radius margin_top">
					<view class="flexbetween">
						<view class="flexleft">
							<view class="strongtext xiaohui margin_right0">全部美食</view>
							<view class="xiasanjx"></view>
						</view>
						<view class="flexleft">
							<view class="strongtext xiaohui margin_right0">离我最近</view>
							<view class="xiasanjx"></view>
						</view>
						<view class="flexleft">
							<view class="strongtext xiaohui margin_right0">智能排序</view>
							<view class="xiasanjx"></view>
						</view>
					</view>
				</view>
			</view> -->
			<view class="ffffff radius mainpadding margin_top" v-for="item in list.data" :key="item.id" @click="jumpdetail('/pages_shouye/mendianxq?id=',item.id)">
				<view class="flexleft">
					<image class="listleftimg radius margin_right2" :src="item.logo_text" mode=""></image>
					<view class="flexcolumnbet" style="height: 140rpx;width: 100%;">
						<view class="titletext hei_text bold">{{item.name}}</view>
						<view class="flexleft">
							<u-icon name="man-add" color="#ff9341" size="16"></u-icon>
							<view class="xiaohuang margin_right margin_left1 strongtext">粉丝{{item.gz_num}}个</view>
							<u-icon name="eye" color="#999" size="16"></u-icon>
							<view class="xiaohui margin_right margin_left1 strongtext">浏览{{item.view_num}}次</view>
						</view>
						<view class="flexbetween" style="width: 100%;">
							<view class="flexleft">
								<u-icon name="map" color="#ff9341" size="16"></u-icon>
								<view class="xiaohui margin_left1 main_size yhxk" style="width: 300rpx;">
									{{item.address_detail}}</view>
							</view>
							<view class="xiaohuang main_size">{{returnKmUnit(Number(item.distance))}}</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				leftlist:[],
				list1: [],
				category_id:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				cityid:"",
				areaid:"",
				lat:"",
				lng:"",
				navname:""
			}
		},
		onLoad(options) {
			let data = JSON.parse(decodeURIComponent(options.msg))
			this.category_id = data.category_id
			this.navname = data.navname
			uni.setNavigationBarTitle({
				title:data.navname
			})
			let storagecity = uni.getStorageSync("storagecity") || null
			if(storagecity){
				this.lat = storagecity.latitude
				this.lng = storagecity.longitude
				this.cityid = storagecity.cityid
			}
			let storagearea = uni.getStorageSync("storagearea") || null
			if(storagearea){
				this.areaid = storagearea.areaid
			}
			this.init()
			this.getfl()
			this.getbanner()
		},
		methods: {
			getbanner() { //获取轮播图
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 4,
					is_more: 1
				}).then(res => {
					this.list1 = res.data
				}).catch(err => {})
			},
			getfl() {
				httpRequest.request('/api/index/shopCategoryChild', 'GET', {
					category_id:this.category_id,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.leftlist = res.data
					}
				})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/shopcl/shopIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
					lat:this.lat,
					lng:this.lng,
					city_id:this.cityid,
					area_id:this.areaid,
					category_id:this.category_id
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpdetail(url, id) {
				uni.navigateTo({
					url: url + id
				})
			},
			// 跳转民宿酒店
			tzmslb() {
				uni.navigateTo({
					url: '/pages_lianmengsc/minsulb'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.flicon {
		margin: auto;
		width: 80rpx;
		height: 80rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}

	.huangbox {
		background-color: #fff5ec;
		padding: 4rpx 7rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		font-size: 22rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
	}

	.fenbox {
		background-color: #fff0ef;
		padding: 4rpx 7rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		font-size: 22rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FB605C;
	}

	.tupian {
		width: 200rpx;
		height: 200rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}

	.hhbtn {
		width: 89rpx;
		height: 37rpx;
		border-radius: 37rpx 37rpx 37rpx 37rpx;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #999999;
		border: 2rpx solid #999999;
	}

	.dqicon {
		width: 30rpx;
		height: 30rpx;
	}

	.bjsdw {
		position: absolute;
		top: 0;
		left: 0;
		z-index: 0;
		width: 100%;
		height: 248rpx;
		background: linear-gradient(0deg, #f9e2d1 0%, #FF9341 100%);
	}
</style>